//=======================================================================
//功能: 			JavaScript 提示框工具类[依赖于jQuery]
//author:		岳静
//e-mail: 		yuejing0129@126.com
//QQ:			503490146
//date: 		2012-08-16
//version: 		1.0
//=======================================================================

/**
 * 通用弹出框函数
 * @param _msg
 */
function alert(_msg){
	var grayDiv= "<div class='alertDialog' style='width:100%; height:100%; position:absolute; background-color:#ddd; top:0; left:0; filter:alpha(opacity=60); -moz-opacity:.60; opacity:0.6; display:block; z-index:99999'></div>";
	var contentDiv="<div class='alertDialogMsg' style='display:none; position:absolute; border:4px solid #ddd; width:500px; padding:10px; background-color:#FFF; left:30%; top:22%; z-index:999; display:block; z-index:999999'>";
	contentDiv += "<h3 style='border-bottom:1px solid #ddd; position:relative; font-size:14px;'>提示信息<span onclick='jsPrompt.closeAlert();' style='background:url(images/delete.png) no-repeat center center; text-indent:-9999px; width:16px; height:16px; display:inline-block; position:absolute; right:0;'>关闭</span></h3>";
	contentDiv += "<p style='padding:10px 0;'>" + _msg + "</p>";
	contentDiv += "<div><input type='button' class='sendBtn' onclick='jsPrompt.closeAlert();' value='确定'/></div>";
	contentDiv += "</div>";
	$("body").append(contentDiv);
	$("body").append(grayDiv);
}

/**
 * 判断框[confirm]
 * @param _msg
 * @param _params: 参数
 * @param _fn	 : 回调函数
 * @returns
 */
function confirmPrompt(_msg, _params, _fn) {
	var grayDiv= "<div class='confirmDialog' style='width:100%; height:100%; position:absolute; background-color:#ddd; top:0; left:0; filter:alpha(opacity=60); -moz-opacity:.60; opacity:0.6; display:block; z-index:99999'></div>";
	var contentDiv="<div class='confirmDialogMsg' style='display:none; position:absolute; border:4px solid #ddd; width:500px; padding:10px; background-color:#FFF; left:30%; top:22%; z-index:999; display:block; z-index:999999'>";
	contentDiv += "<h3 style='border-bottom:1px solid #ddd; position:relative; font-size:14px;'>提示信息<span onclick='jsPrompt.closeConfirm();' style='background:url(images/delete.png) no-repeat center center; text-indent:-9999px; width:16px; height:16px; display:inline-block; position:absolute; right:0;'>关闭</span></h3>";
	contentDiv += "<p style='padding:10px 0;'>" + _msg + "</p>";
	contentDiv += "<div><input type='button' class='sendBtn' onclick='jsPrompt.yesConfirm();' value='确定'/>";
	contentDiv += "<input type='button' class='sendBtn' onclick='jsPrompt.closeConfirm();' value='取消'/></div>";
	contentDiv += "</div>";
	$("body").append(contentDiv);
	$("body").append(grayDiv);
	//处理回调函数
	jsPrompt.callback = _fn;
	//处理参数
	jsPrompt.params = _params;
}

var jsPrompt = {
		/**
		 * 关闭Alert
		 */
		closeAlert : function() {
			$("div").remove(".alertDialog");
			$("div").remove(".alertDialogMsg");
		},

		/**
		 * 关闭Confirm
		 */
		closeConfirm : function() {
			$("div").remove(".confirmDialog");
			$("div").remove(".confirmDialogMsg");
		},

		/**
		 * 执行Confirm的确定事件
		 */
		yesConfirm : function() {
			jsPrompt.callback(jsPrompt.params);
			//关闭
			jsPrompt.closeConfirm();
		}
};